#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QColorDialog>
#include <QFileDialog>
#include<QDebug>
#include <QInputDialog>
#include <QFontDialog>
#include <QMessageBox>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_filebt_clicked()
{
    QFileDialog filedialog;
    QString filename;

    filedialog.show();
    filename=QFileDialog::getOpenFileName(this);
    qDebug()<<filename;

//    QFileDialog filedialog2;
//    connect(&filedialog2,&QFileDialog::fileSelected, [&](const QString &filename)->void{
//        qDebug()<<filename;
//    });
//    filedialog2.exec();

    ui->filelb->setText(filename);
}

void MainWindow::on_colorbt_clicked()
{
    QColor color=QColorDialog::getColor();
    qDebug()<<color.name();
    ui->colorlb->setStyleSheet(QString("background-color:%1").arg(color.name()));
}

void MainWindow::on_inputbt_clicked()
{
    QString text=QInputDialog::getText(this,"输入","输入密码",QLineEdit::Password);
    ui->inputlb->setText(text);
}

void MainWindow::on_fontbt_clicked()
{
    bool ok=false;
    QFont font=QFontDialog::getFont(&ok,this);
    if(ok){
        ui->fontlb->setFont(font);
    }
}

void MainWindow::on_messagebt_clicked()
{
    int ret=QMessageBox::warning(this,"提示","你确定？",QMessageBox::Yes,QMessageBox::No);
    if(ret==QMessageBox::Yes){
        qDebug()<<"你点击了Yes";
    }else{
        qDebug()<<"你点击了No";
    }
}
